package com.bianmaba.activiti.service.authorization.resource;

import com.bianmaba.spring.web.service.BaseService;
import com.bianmaba.activiti.beans.entity.authorization.Resource;
import com.bianmaba.activiti.repository.authorization.resource.ResourceRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by cwx183898 on 2017/8/9.
 */
@Service
public class ResourceService extends BaseService<Resource, String> implements IResourceService {
    @Autowired
    private ResourceRepository repository;

    @Override
    public ResourceRepository getRepository() {
        return repository;
    }

    @Override
    public Resource save(Resource entity) {
        if (entity.getId() == null) {
            entity.setCreator("SYSTEM");
        }
        return super.save(entity);
    }

    @Override
    public List<String> findRoleNames(String resource) {
        return getRepository().findRoleNames(resource);
    }
}
